using System;
using System.Collections.Generic;
using System.Text;
using java.net;
using org.apache.mina.common;
using java.util.concurrent;
using org.apache.mina.transport.socket.nio;

namespace PDSClient.Utils.IO.Impl
{
    public class SocketEndpoint : AbstractSocketEndpoint, IEndpoint<SocketAddress>
    {
        public SocketEndpoint(SocketAddress address, TransportType type) : base(address, type)
        {
        }
        public SocketEndpoint(SocketAddress address, TransportType type, Executor executor)
            : base(address, type, executor, 1)
        { 
        }
        public SocketEndpoint(SocketAddress address, TransportType type, Executor executor, int numProcessors)
            : base(address, type, executor, numProcessors)
        { 
        }


        public IConnector<SocketAddress> CreateConnector()
        {
            IoConnector minaConnector;
            if (transportType.Equals(TransportType.RELIABLE))
            {
                minaConnector = new org.apache.mina.transport.socket.nio.SocketConnector(
                    numProcessors, executor);
            }
            else
            {
                minaConnector = new DatagramConnector(executor);
            }
            SocketConnector connector = new SocketConnector(this, minaConnector);
            //logging logger.log(Level.FINE, "returning {0}", connector);
            return connector;
        }
    }
}
